Dynomotion

Group: DynoMotion Message: 7787 From: babinda01 Date: 6/26/2013
Subject: Spindle Speed
Hi Guys
I am setting up a machine using KMotionCNC and KFlop/Analog Boards.
I have my axis working and spindle turning on and off as well as speed control. I am using a SuperPID speed controller, which has a 1 pulse per rev tach signal. Can someone please point me in the right direction for how to read this pulse (connected to Opto input 1 at this stage) and display it on the KMotionCNC screen, so that I can have actual speed as well as commanded speed. I would then like to add the ability to feedhold the system if the speed falls below a certain percentage of the commanded speed.

Thanks
Andrew
Group: DynoMotion Message: 7788 From: Tom Kerekes Date: 6/26/2013
Subject: Re: Spindle Speed
Attachments :
Hi Andrew,

KMotionCNC (and Mach3) currently needs a Position Count related to Spindle Revs to display Spindle Speed.  Normally there is a quadrature Encoder on the Spindle for this purpose.

I think if you just have a 1 pulse per rev tach signal you can fake an encoder count with software that watches the Tach signal.  The Tach pulses are pretty slow.

20,000 RPM = 0.003 sec per rev

Hopefully your Tach signal is about a 50% duty cycle, but even if it is 25/75% that would be at least 0.003/4 = 750us per state.

KFLOP user programs run every 180us so you should be able to count states with a User Program.

I've attached a program to count states and on every rising edge of the tach signal it will increment an Axis Position similarly to what an encoder would do.  Modify the program to update the Position of one of your unused Axis channels and configure that axis channel to Input Mode = No Input or User Input.  

You can then configure KMotionCNC (or Mach3) to watch that Axis Channel for Spindle Display.  Set the counts/rev to 1

The Attached User Program also shows how to access the currently measured Spindle Speed (Spindle.TrueSpeedRPS).  You can watch it and feed hold under certain circumstances.  I suppose you will need your Spindle Program to save the currently commanded speed in a Global Persist Variable so that you can have something to compare and also know if it should be comparing.

Another approach would be to use a Hardware Encoder input.  The Hardware encoders need A/B quadrature and you only have a single Tach signal.  I think you can create a phase shifted version of the Tach signal that will work as a B signal.  I fed a 3.3V square wave into KFLOP JP6 Pin5.  Then connected a 50 ohm to Pin6 and put a 0.2uF Cap from Pin6 to GND and it worked well.  (I switched encoders from JP5 to JP6 with FPGAW(ENC_NOISE_FILTER_ADD)=0x100+7;)

HTH
Regards
TK